import SwiftUI

// 广告卡片模型
struct AdCard: Identifiable {
    let id = UUID()
    let title: String
    let image: String
    let height: CGFloat
}

// Banner组件
struct BannerView: View {
    let title: String
    
    var body: some View {
        Text(title)
            .frame(maxWidth: .infinity)
            .frame(height: 150)
            .background(Color.gray.opacity(0.2))
            .cornerRadius(10)
    }
}

// 快捷入口网格组件
struct QuickEntryGridView: View {
    let items: [QuickEntryItem]
    
    var body: some View {
        LazyVGrid(columns: Array(repeating: GridItem(.flexible()), count: 4), spacing: 15) {
            ForEach(items) { item in
                VStack {
                    Image(systemName: item.iconName)
                        .font(.system(size: 24))
                        .foregroundColor(.blue)
                    Text(item.title)
                        .font(.caption)
                }
            }
        }
    }
}

// 促销视图组件
struct PromotionView: View {
    let title: String
    
    var body: some View {
        Text(title)
            .frame(maxWidth: .infinity)
            .frame(height: 100)
            .background(Color.orange.opacity(0.2))
            .cornerRadius(10)
    }
}

// 瀑布流视图组件
struct WaterfallGrid: View {
    let items: [AdCard]
    let columns: Int
    
    let colors: [Color] = [
        .blue.opacity(0.3),
        .green.opacity(0.3),
        .orange.opacity(0.3),
        .purple.opacity(0.3),
        .pink.opacity(0.3)
    ]
    
    var body: some View {
        GeometryReader { geometry in
            let width = (geometry.size.width - CGFloat(columns - 1) * 10) / CGFloat(columns)
            
            ScrollView {
                LazyVGrid(columns: Array(repeating: GridItem(.fixed(width), spacing: 10), count: columns), spacing: 10) {
                    ForEach(Array(items.enumerated()), id: \.element.id) { index, item in
                        VStack {
                            Rectangle()
                                .fill(colors[index % colors.count])
                                .frame(width: width, height: item.height)
                                .cornerRadius(10)
                            
                            Text(item.title)
                                .font(.caption)
                                .lineLimit(2)
                        }
                    }
                }
                .padding()
            }
        }
    }
} 
